<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
    var arr=[12,43,54,42,56,31,33,77,32,67,32]
    for(var i=0;i<arr.length;i++){
        var min=arr[i];
        var minindex=i;
        for(var j=i+1;j<arr.length;j++){
            if(arr[j]<min){
               min=arr[j];
               minindex=j;
               console.log(min,minindex)
               arr[minindex]=arr[i];
               arr[i]=min;
            }
        }
        console.log(arr)
    }
    
    </script>
</body>
</html>